package model;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import com.et.ar.ActiveRecordBase;
import com.et.ar.annotations.Column;
import com.et.ar.annotations.DependentType;
import com.et.ar.annotations.HasMany;
import com.et.ar.annotations.Id;
import com.et.ar.annotations.Table;
import com.et.mvc.JsonView;
/**
 * @author wzzz
 * @date 2011-3-20 下午08:03:50
 * @desc 系统功能表
 * 
 */
@Table(name = "sys_menu")
public class Sys_menu extends ActiveRecordBase {
	@Id
	private Integer id; // 序号
	@Column
	private String menu_name;// 功能名称
	@Column
	private String image;// 功能菜单的图标

	@HasMany(foreignKey = "sys_menuId", dependent = DependentType.DELETE, order = "id")
	private List<Sys_sub_menu> sys_sub_menu;

	@HasMany(foreignKey = "sys_menuId_priv", dependent = DependentType.DELETE, order = "id")
	// private List<User_priv> user_priv;
	//
	// public List<User_priv> getUser_priv() {
	// return user_priv;
	// }
	//
	// public void setUser_priv(List<User_priv> userPriv) {
	// user_priv = userPriv;
	// }
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getMenu_name() {
		return menu_name;
	}

	public void setMenu_name(String menuName) {
		menu_name = menuName;
	}

	public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	public List<Sys_sub_menu> getSys_sub_menu() {
		return sys_sub_menu;
	}

	public void setSys_sub_menu(List<Sys_sub_menu> sysSubMenu) {
		sys_sub_menu = sysSubMenu;
	}

	// 根据子功能编号，返回主功能菜单
	public List<String> getMenunames() throws Exception {
		List<Sys_menu> sysmenu = Sys_menu.findAll(Sys_menu.class);
		List<String> menu_names = new ArrayList<String>();
		Iterator<Sys_menu> it = sysmenu.iterator();
		while (it.hasNext()) {
			Sys_menu sm = (Sys_menu) it.next();
			menu_names.add(sm.getMenu_name());
		}
		return menu_names;
	}
}
